#include "stdafx.h"

#include "HidReport.h"

HidReport::HidReport(UInt16 ReportSize)
{
	_Data = gcnew array<Byte>(ReportSize - 1);
}

HidReport::HidReport(UInt16 ReportSize, HidDeviceData^ DeviceData)
{
	_Status = DeviceData->Status;

	if(DeviceData->Data != nullptr)
	{
		if(DeviceData->Data->Length > 0)
		{
			_ReportId = DeviceData->Data[0];
			_Exists = true;

			if(DeviceData->Data->Length > 1)
			{
				int DataLength = ReportSize - 1;
				if(DeviceData->Data->Length < DataLength)
				{
					DataLength = DeviceData->Data->Length;
				}
				_Data = gcnew array<Byte>(DataLength);
				Array::Copy(DeviceData->Data, 1, _Data, 0, DataLength);
				return;
			}
		}
	}
	_Exists = false;
}

array<Byte>^ HidReport::GetBytes()
{
	array<Byte>^ Data1 = gcnew array<Byte>(_Data->Length + 1);
	Data1[0] = _ReportId;
	Array::Copy(_Data,0,Data1,1,_Data->Length);
	return Data1;
}